package com.example.questionsystem.modules.qu.enums;

public enum QuestionTypeEnum {
    JUDGMENT("判断题", 1),
    SINGLE_CHOICE("单项选择题", 2),
    MULTIPLE_CHOICE("多项选择题", 3),
    INDEFINITE_CHOICE("不定项", 4),
    FILL_IN_THE_BLANK("填空题", 5),
    SHORT_ANSWER("简答题", 6),
    ANALYTICAL("分析题", 7),
    WRITING("写作题", 8),
    SPEED_RECORDING("速录题", 9),
    COMPREHENSIVE("综合题", 10),
    FORM_FILLING("表格题", 11);

    private final String name;
    private final int code;

    QuestionTypeEnum(String name, int code) {
        this.name = name;
        this.code = code;
    }

    public static Integer getCodeByName(String name) {
        for (QuestionTypeEnum type : values()) {
            if (type.name.equals(name)) {
                return type.code;
            }
        }
        return null; // 未找到时返回null，可根据需求改为抛出异常
    }

    // 可选反向查询方法
    public static String getNameByCode(int code) {
        for (QuestionTypeEnum type : values()) {
            if (type.code == code) {
                return type.name;
            }
        }
        return "未知题型";
    }
}
